
import requests
import os
from lamda.client import * 

API_URL = "http://127.0.0.1:8000/api/getSpace"

d = Device("192.168.12.4",65008)
backgroundImg = d(resourceId = "captcha-verify-image")
#backgroundBytes = backgroundImg.screenshot(quality = 100).getvalue()
backgroundImgs = backgroundImg.screenshot(quality=100).save("output.png")


content_type = 'image/png'
headers = {
    'Content-Type' : content_type
}

response = requests.post(url= API_URL,data=backgroundImgs,headers=headers,timeout=50)
response.raise_for_status()
result_data = response.json()
print("\n--- ✅ 请求成功! ---\n")
print(f"服务器响应状态码: {response.status_code}")
print(f"收到的 JSON 结果: {result_data}")
postition = result_data.get('target_x_position')
if postition is not None:
    print(f"\n分析结果 -> 目标 X 坐标是: {postition}")
else:
    print("\n警告：响应中未找到 'target_x_position' 字段。")